package se.djupfeldt.oscar.logbook.indata;

import java.util.Arrays;


public class Sentence {
    protected String sentence[];
    protected String raw;
    
    protected Sentence(String s) {
	sentence = s.split("[,\\*]");
	raw = s;
    }
    
    protected Sentence(String[] s) {
	sentence = s;
	raw = Arrays.toString(s);
    }

    public static Sentence getSentence(String s) throws SentenceException {
	if (s.startsWith("$")) {
	    return new Sentence(s);
	}
	else throw new SentenceException("Malformed sentence: " + s);
    }
    
    public int getSentenceLength() {
	return sentence.length - 1;
    }
    
    public String[] getSentenceArray() {
	return sentence;
    }
    
    public String getID() {
	return sentence[0].substring(1);
    }
    
    public String getRaw() {
	return raw;
    }
    
    @Override
    public String toString() {
        return Arrays.toString(sentence);
    }

    public String getName() {
	return sentence[0].substring(3);
    }
}
